﻿<UserControl x:Class="EnergyGeneratorSimVisualizer.Views.ChartView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             xmlns:ds="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             x:Name="root">
    <UserControl.Resources>
        <Style x:Key="legendStyle" TargetType="{x:Type ds:Legend}">
            <Setter Property="Width"
                    Value="0" />
            <Setter Property="Height"
                    Value="0" />
        </Style>
        <Style x:Key="dataPointStyle" TargetType="{x:Type charting:LineDataPoint}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type charting:LineDataPoint}">
                        <Rectangle Width="2"
                                   Height="2"
                                   Fill="Black" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <charting:Chart Title="{Binding ElementName=root, Path=Title}"
                        LegendStyle="{StaticResource legendStyle}">
            <charting:Chart.Axes>
                <charting:LinearAxis Orientation="Y"
                               ShowGridLines="True"
                               Title="Wert"
                               x:Name="YAxis" />
                <charting:CategoryAxis Orientation="X"
                                 Title="Zeit"
                                 x:Name="XAxis" />
            </charting:Chart.Axes>
            <charting:Chart.Series>
                <charting:LineSeries Title="Serie"
                               IndependentValueBinding="{Binding Zeit}"
                               ItemsSource="{Binding ProcessedData}"
                               IndependentAxis="{Binding ElementName=XAxis}"
                               DependentRangeAxis="{Binding ElementName=YAxis}"
                                     DataPointStyle="{StaticResource dataPointStyle}">
                    <charting:LineSeries.DependentValueBinding>
                        <Binding x:Name="ValueBinding" />
                    </charting:LineSeries.DependentValueBinding>
                </charting:LineSeries>
            </charting:Chart.Series>
        </charting:Chart>
    </Grid>
</UserControl>
